﻿<UserControl x:Class="MediaOwl.WebSearch.Views.BingVideoSearchView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:ctrl="clr-namespace:MediaOwl.Common.ControlTemplates;assembly=MediaOwl.Common"
             xmlns:System="clr-namespace:System;assembly=mscorlib"
             mc:Ignorable="d"
             d:DesignHeight="569"
             d:DesignWidth="833">

    <UserControl.Resources>
        <DataTemplate x:Key="SearchResultItemTemplate">
            <Border Margin="5"
                    Background="{StaticResource DarkInnerShadowDarkBrush}"
                    BorderBrush="{StaticResource DarkBorder}"
                    BorderThickness="1">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="TemplateVStateGroup"
                                      ei:ExtendedVisualStateManager.UseFluidLayout="True">
                        <VisualStateGroup.Transitions>
                            <VisualTransition GeneratedDuration="0:0:0.5">
                                <VisualTransition.GeneratedEasingFunction>
                                    <CubicEase EasingMode="EaseIn" />
                                </VisualTransition.GeneratedEasingFunction>
                            </VisualTransition>
                            <VisualTransition From="Normal"
                                              GeneratedDuration="0:0:0.2"
                                              To="MouseOver">
                                <VisualTransition.GeneratedEasingFunction>
                                    <CircleEase EasingMode="EaseIn" />
                                </VisualTransition.GeneratedEasingFunction>
                            </VisualTransition>
                        </VisualStateGroup.Transitions>
                        <VisualState x:Name="Normal" />
                        <VisualState x:Name="MouseOver">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)"
                                                               Storyboard.TargetName="border">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <System:Double>62</System:Double>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <VisualStateManager.CustomVisualStateManager>
                    <ei:ExtendedVisualStateManager />
                </VisualStateManager.CustomVisualStateManager>
                <Grid Height="180"
                      Width="180">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="MouseEnter">
                            <ei:GoToStateAction StateName="MouseOver" />
                        </i:EventTrigger>
                        <i:EventTrigger EventName="MouseLeave">
                            <ei:GoToStateAction StateName="Normal" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <Image Source="{Binding StaticThumbnail.Url}"
                           Height="180"
                           Width="180" />
                    <Border x:Name="border"
                            VerticalAlignment="Bottom"
                            BorderThickness="0,1,0,0"
                            Background="{StaticResource ReadOnlyBrush}"
                            BorderBrush="{StaticResource DarkBorder}"
                            Height="17">
                        <toolkit:DockPanel Margin="2">
                            <TextBlock toolkit:DockPanel.Dock="Top"
                                       Text="{Binding Title}"
                                       Style="{StaticResource Heading6}"
                                       TextWrapping="Wrap"
                                       Height="15"
                                       FontSize="12" Margin="0" />
                            <HyperlinkButton Content="{Binding SourceTitle}"
                                       Foreground="{StaticResource ControlHighlight}"
                                       toolkit:DockPanel.Dock="Top"
                                       HorizontalAlignment="Stretch"
                                       FontSize="10.667"
                                       Height="14" Margin="0" NavigateUri="{Binding ClickThroughPageUrl}" TargetName="_media" />
                            <TextBlock Text="{Binding RunTime, Converter={StaticResource timeSpanConverter}}"
                            	Foreground="{StaticResource ControlHighlight}"
								toolkit:DockPanel.Dock="Top"
                            	HorizontalAlignment="Stretch"
                            	FontSize="10.667"
                            	Height="14"
                            	Margin="0" />
                        </toolkit:DockPanel>
                    </Border>
                </Grid>
            </Border>
        </DataTemplate>
    </UserControl.Resources>
    <ctrl:WorkitemControl BusyContext="{Binding CurrentBusyViewModel}"
                          DialogContext="{Binding ActiveDialog}">
        <toolkit:DockPanel Margin="5">

            <toolkit:DockPanel LastChildFill="False"
                               Margin="0,0,0,5"
                               toolkit:DockPanel.Dock="Top">
                <TextBlock x:Name="DisplayName"
                           TextWrapping="Wrap"
                           toolkit:DockPanel.Dock="Top"
                           Style="{StaticResource Heading2}"
                           Margin="0,0,0,10" />
                <toolkit:Expander Header="Filter" toolkit:DockPanel.Dock="Bottom" >
                	<StackPanel Orientation="Horizontal">
                		<ListBox x:Name="Durations" FontSize="10.667" SelectedItem="{Binding SelectedDuration, Mode=TwoWay}" MinWidth="120" Margin="0,0,5,0"/>
                		<ListBox x:Name="Aspects" FontSize="10.667" SelectedItem="{Binding SelectedAspect, Mode=TwoWay}" MinWidth="120" Margin="0,0,5,0"/>
                		<ListBox x:Name="Resolutions" FontSize="10.667" SelectedItem="{Binding SelectedResolution, Mode=TwoWay}" MinWidth="120" Margin="0,0,5,0"/>
                	</StackPanel>
                </toolkit:Expander>
                <TextBlock x:Name="SearchResultText"
                           Foreground="{StaticResource ControlForeground}"
                           MinHeight="20"
                           Margin="0,2,0,0"
                           toolkit:DockPanel.Dock="Bottom" />
                <TextBox x:Name="SearchText"
                         TextWrapping="Wrap"
                         Margin="0,0,10,0"
                         MinWidth="150"
                         VerticalAlignment="Top">
                    <i:Interaction.Triggers>
                        <ei:KeyTrigger Key="Enter">
                            <cal:ActionMessage MethodName="SearchShortCut" />
                        </ei:KeyTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
                <Button x:Name="SearchItems"
                        Content="Search"
                        Margin="0,0,10,0"
                        VerticalAlignment="Top" />
                <StackPanel Orientation="Horizontal"
                            HorizontalAlignment="Right"
                            toolkit:DockPanel.Dock="Right">
                    <Button x:Name="Previous"
                            Content="Previous"
                            d:LayoutOverrides="Height" />
                    <toolkit:NumericUpDown x:Name="ItemsPerPage"
                                           Increment="10"
                                           Minimum="1"
                                           Margin="5,0"
                                           Width="60" />
                    <Button x:Name="Next"
                            Content="Next"
                            d:LayoutOverrides="Height"
                            Margin="0" />
                </StackPanel>
            </toolkit:DockPanel>
            <ListBox x:Name="Results"
                     ItemTemplate="{StaticResource SearchResultItemTemplate}"
                     d:LayoutOverrides="Height"
                     Background="Transparent"
                     ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                     SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                     ItemsPanel="{StaticResource WrappingItemsPanelTemplate}">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged">
                        <cal:ActionMessage MethodName="Open" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </ListBox>

        </toolkit:DockPanel>
    </ctrl:WorkitemControl>
</UserControl>
